import http from '@/request/http_81';
import config from '@/config';

export async function doLogin(values) {
    let { data: res } = await http.post(`${config.server_projectName}-user/user/login`,values);
    return res;
}

export async function doLoginForEmail(values) {
    let { data: res } = await http.post(`${config.server_projectName}-user/user/login/email`, values);
    return res;
}

export async function uploaderAvatar(avatarFormData) {
    // let { data: res } = await http.post('${config.server_projectName}-user/user/info/update/avatar', avatarFormData);
    // return res;
    return http.post(`${config.server_projectName}-user/user/info/update/avatar`, avatarFormData);
}

export function updateUserInfo(values) {
    return http.post(`${config.server_projectName}-user/user/info/update/info`, values);
}

export async function sendEmail(email) {
    let { data: res } = await http.get(`${config.server_projectName}-user/user/register/obtain/email/authCode/${email}`);
    return res;
}

export async function verifyEmail(email) {
    let { data: res } = await http.get(`${config.server_projectName}-user/user/login/obtain/email/authCode/${email}`);
    return res;
}

export async function getUserInfo() {
    let { data: res } = await http.get(`${config.server_projectName}-user/user/info/get/info`);
    return res;
}

export async function doRegin(values) {
    console.log(values)
    // let { data: res } = await http.post('${config.server_projectName}-user/user/register', {
    //     account: values.account,
    //     bindingEmail: {
    //         authCode: values.authCode,
    //         email: values.email
    //     },
    //     password: values.password,
    //     userName: values.userName
    // });
    let { data: res } = await http.post(`${config.server_projectName}-user/user/register`, values);
    return res;
}